<?php

namespace app\common\model\mysql;
use think\model;
class AdminUser extends model
{
    /**
     * 根据用户名获取后端表数据
     * @param $username
     * @return AdminUser|array|false|Model|null
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function getAdminUserByUsername($username){
        if(empty($username)){
            return false;
        }

        $where = [
            'username'=>trim($username)
        ];
        $result = $this->where($where)->find();
        return $result;
    }

    /**
     * 根据主键id数据表信息
     * @param $id
     * @param $data
     * @return false|void
     */
    public function updateById($id,$data){
        $id = intval($id);
        if (empty($id)||empty($data)||!is_array($data)){
            return false;
        }
        $where=[
            'id'=>$id,
        ];

        return $this->where($where)->save($data);
    }
}